// API配置文件
const config = {
  // 开发环境配置
  development: {
    baseURL: 'http://localhost:3000/api',
    timeout: 10000,
    uploadURL: 'http://localhost:3000/api/upload',
    wsURL: 'ws://localhost:3000/ws'
  },
  
  // 测试环境配置
  test: {
    baseURL: 'https://test-api.yourdomain.com/api',
    timeout: 15000,
    uploadURL: 'https://test-api.yourdomain.com/api/upload',
    wsURL: 'wss://test-api.yourdomain.com/ws'
  },
  
  // 生产环境配置
  production: {
    baseURL: 'https://api.yourdomain.com/api',
    timeout: 20000,
    uploadURL: 'https://api.yourdomain.com/api/upload',
    wsURL: 'wss://api.yourdomain.com/ws'
  }
}

// 获取当前环境配置
const getConfig = () => {
  const env = process.env.NODE_ENV || 'development'
  return config[env] || config.development
}

// 导出配置
export default getConfig()

// 导出环境判断
export const isDev = process.env.NODE_ENV === 'development'
export const isTest = process.env.NODE_ENV === 'test'
export const isProd = process.env.NODE_ENV === 'production'

// API版本
export const API_VERSION = 'v1'

// 请求头配置
export const headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'X-API-Version': API_VERSION
}

// 错误码配置
export const errorCodes = {
  SUCCESS: 200,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  INTERNAL_ERROR: 500,
  BAD_REQUEST: 400,
  VALIDATION_ERROR: 422
}

// 状态码配置
export const statusCodes = {
  PENDING: 'pending',
  PROCESSING: 'processing',
  COMPLETED: 'completed',
  CANCELLED: 'cancelled',
  FAILED: 'failed'
}

// 文件上传配置
export const uploadConfig = {
  maxSize: 10 * 1024 * 1024, // 10MB
  allowedTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf'],
  maxFiles: 5
}

// 缓存配置
export const cacheConfig = {
  // 缓存时间（毫秒）
  userInfo: 5 * 60 * 1000, // 5分钟
  inventoryList: 2 * 60 * 1000, // 2分钟
  taskList: 1 * 60 * 1000, // 1分钟
  messageList: 30 * 1000, // 30秒
} 